package com.yjhb.android.sbz.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.borjabravo.readmoretextview.ReadMoreTextView;
import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.entity.SystemNotice;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;
import com.jojo.android.zxlib.tool.ZxTimeTool;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 创建者 zx
 * 创建时间 2021/1/11 11:16
 */
public class SystemNoticeAdapter extends BaseRecyclerAdapter<SystemNoticeAdapter.Holder, SystemNotice> {
    private final String TAG = "SystemNoticeAdapter";


    public SystemNoticeAdapter(Context context) {
        super(context);
    }

    @Override
    protected Holder getHolder(View v) {
        return new Holder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_system_notice;
    }

    @Override
    public void onBindViewHolder(@NonNull Holder holder, int position) {
        holder.contentTv.setText(entity.getContent());
        holder.dateTv.setText(ZxTimeTool.getDate(entity.getTime().getTime(),"yyyy-MM-dd HH:mm"));
    }


    class Holder extends RecyclerView.ViewHolder {
        @BindView(R.id.title_tv)
        TextView titleTv;
        @BindView(R.id.date_tv)
        TextView dateTv;
        @BindView(R.id.content_tv)
        ReadMoreTextView contentTv;

        public Holder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
            contentTv.setTrimCollapsedText("展开");
            contentTv.setTrimExpandedText("收起");
        }
    }

}
